package com.starinside.wp.repository;

import com.starinside.wp.domain.CheckRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;


/**
 * *******************************
 * Created by Tim.
 * form com.matt
 * on 2017/7/25
 * *******************************
 */
@Repository
public interface CheckRecordRepository extends JpaRepository<CheckRecord, String> {

    List<CheckRecord> findByChildrenIdOrderByCheckInTimeDesc(String childrenId);

    @Query("select c from CheckRecord c where c.childrenId=?1 and c.created>= ?2  and c.created<= ?3 and c.height IS NOT NULL and c.weight IS NOT NULL order by c.created ")
    List<CheckRecord> findByChildrenIdAndCreatedBetween(String childrenId, Date beginDate, Date endDate);

    List<CheckRecord> findByCheckInTimeBetweenAndChildrenIdInAndCheckOutTimeIsNull(Date begin, Date end, String[] childrenIds);

    @Query(value = "select * from check_record cr " +
            " where childrenId=?1 and checkInTime>=CONCAT(?2, ' 00:00')" +
            " and checkInTime < DATE_ADD(CONCAT(?2, ' 00:00'), INTERVAL 1 DAY)", nativeQuery = true)
    List<CheckRecord> findDayRecordByChildrenId(String childrenId, String day);

//    List<ChildrenCheckRecordVO> findByClasses(String classesId);
//
//    Integer findClienteleCountByDateAndAreaId(String beginDate, String endDate, String areaId);
//
//    Integer findTeacherCountByDateAndAreaId(String beginDate, String endDate, String areaId);
//
//    Integer findCheckInCountByDateAndAreaId(String date, String areaId);
//
//    Integer findCheckOutCountByDateAndAreaId(String date, String areaId);
//
//    Integer findCheckInCountByDateAndClienteleIds(String date, List<String> clienteleIds);
//
//    Integer getTeacherCheckInCount(String staffId, String date);
//
//    Integer getTeacherCheckOutCount(String staffId, String date);
//
//    Integer getAreaChildCheckInCount(String areaId, String date);
//
//    Integer getNurseryCheckInCount(String staffId, String date);
//
//    Integer getNurseryCheckOutCount(String staffId, String date);
}
